# -*- coding: utf-8 -*-
"""
Created on Thu Apr  1 12:20:40 2021
@author: 野生动力煤分析师
"""
import time
from trainer.multi_ml_runner import run_a_y
from multiprocessing import Process
from tjd_config.ini_data import ini_y_data
from tjd_config.config import load_config
from tjdutils.utils import output_dir
from gui.tk_mpl import From


def main(mode='train'):
    output_dir()
    if mode == 'train':
        cfg = load_config()
        y_df = ini_y_data(cfg)
        y_li = y_df.columns.to_list()
        for y_name in y_li[:]:
            print('target name >> ', y_name, ' run after 3 s')
            time.sleep(3)
            p = Process(target=run_a_y, args=(y_name,))
            p.start()
            p.join()
            p.close()
    elif mode == 'back_test':
        print('back_test')
        form = From()
        form.root.mainloop()


if __name__ == "__main__":
    main('train')
    main('back_test')
